﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Strategy
{
    public class Hand
    {
        public static readonly int HandValueGuu = 0;
        public static readonly int HandValueCho = 1;
        public static readonly int HandValuePaa = 2;
        public static readonly Hand[] Hands = {
                                                 new Hand(HandValueGuu),
                                                 new Hand(HandValueCho),
                                                 new Hand(HandValuePaa),
                                             };

        private static readonly string[] name = {
                                                    "グー",
                                                    "チョキ",
                                                    "パー",
                                                };

        private int handValue;

        private Hand(int handValue)
        {
            this.handValue = handValue;
        }

        public static Hand GetHand(int handvalue)
        {
            return Hands[handvalue];
        }

        public bool IsStrongerThan(Hand h)
        {
            return Fight(h) == 1;
        }

        public bool IsWeakerThan(Hand h)
        {
            return Fight(h) == -1;
        }


        private int Fight(Hand h)
        {
            if (this == h)
            {
                return 0;
            }
            else if ((this.handValue + 1) % 3 == h.handValue)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public override string ToString()
        {
            return name[handValue];
        }
    }
}
